package com.my.bigsite.modules.sys.service;

import java.util.HashMap;
import java.util.Map;

import org.activiti.engine.identity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.my.bigsite.common.mybatis.MybatisDao;
import com.my.bigsite.common.util.MD5Util;
import com.my.bigsite.modules.sys.dao.IUserDao;
@Service
public class UserService implements IUserDao {

	@Autowired
	private MybatisDao mybatisDao;  
	@Override
	public Boolean checkPassword(String userId, String password) {
		System.out.println("登陆用户名:"+userId);
			//String systemId = (String) param.get("SYSTEMID");
			String userAccount = userId;
			Map<String, Object> param=new HashMap<String,Object>();
			param.put("USERACCOUNT", userId);
			Map<String, Object> resultMap = mybatisDao.get("UserMapper.userLogin", param);
			if (resultMap == null || resultMap.size() <= 0) {
				return false;
			}
			// 判断密码
			String strRandom = (String) resultMap.get("RANDOM");
			System.out.println("登陆密码盐值:"+strRandom);
			String dbpassword = (String) resultMap.get("PASSWORD");
			password = MD5Util.md5(password + strRandom);
			System.out.println("登陆密码:"+password);
			if (!password.equals(dbpassword)) {
				return false;
			}
		return true;
	}
}
